# Maintainer: Anatol Pomozov <anatol.pomozov@gmail.com>

pkgname=rubygems
pkgdesc='Package management framework for Ruby'
pkgver=2.7.7
pkgrel=1
arch=(any)
url='https://rubygems.org/'
license=(MIT)
# To avoid circular dependency with ruby, move it to makedepends
makedepends=(ruby)
backup=(etc/gemrc)
checkdepends=(rake)
source=(rubygems-$pkgver.zip::https://github.com/rubygems/rubygems/archive/v${pkgver}.zip
        gemrc)
sha512sums=('4b57e7939946f1a6ff1eb7ee57be09cc17416c1bdf7c1936091627307fbce07ba5009c4cb754e809d9748c3b828575e64865307699160feae92f270c197db43c'
            '8cafd14d414ee3c16aa94f79072bc6c100262f925dc1300e785846c3fabbbbffc1356b8e2223af5684e3340c55032d41231179ffa948bb12e01dbae0f4131911')

check() {
  cd rubygems-${pkgver}

  # disable as it requires a bund of ruby dependencies
  #rake test
}

package() {
  depends+=(ruby)
  cd rubygems-${pkgver}

  install -D -m644 ${srcdir}/gemrc "${pkgdir}/etc/gemrc"

  local rubyver=$(ruby --version | sed -r 's|^ruby ([[:digit:]]+\.[[:digit:]]+\.).*$|\1|')0

  install -d "${pkgdir}/usr/lib/ruby/${rubyver}/"
  install -D -m755 bin/gem "${pkgdir}/usr/bin/gem"
  cp -r lib/* "${pkgdir}/usr/lib/ruby/${rubyver}/"
  install -D -m644 MIT.txt "${pkgdir}/usr/share/licenses/rubygems/MIT.txt"
}
